#use strict;
use warnings;
use Plack::Request;
use Imager;
my $app = sub(){
        $env = shift;
        $rec = Plack::Request->new( $env );
        $path_info = $rec->path_info; 
        $path_info =~ s/^.//g;
        $img = Imager->new;
        $img->read( file => $path_info);
        $img = $img->scale(
                    xpixels => 120,
                    ypixels => 120,
                        );
        $savefile = "./data/$path_info";
        if (!-f $savefile){
#            $img->write( file => "$savefile" );
        }
        my $res = $rec->new_response( 200 );
        $res->content_type('text/html');
        $body = "<img src=\"http://www37172u.sakura.ne.jp/test/data/$path_info\" /></a>\n$path_info\n$img";
        $res->body($body);
        return $res->finalize;
};
